#pragma once
#include "VirtualGlobe.h"
#include "Frame.h"
//#include "DynamicData.h"



namespace VIS
{
	class CGlobeFrame : public CFrame
	{
		friend class CGlobeCanvas;

	public:
		static CGlobeFrame *Create(CControlFrame* _cf,const wxString& title, const wxPoint& pos,
			const wxSize& size, long style = wxDEFAULT_FRAME_STYLE);

		CGlobeFrame(CControlFrame* _cf, const wxString& title, const wxPoint& pos,
			const wxSize& size, long style = wxDEFAULT_FRAME_STYLE);

		~CGlobeFrame(void){};

		CGlobeCanvas *GetCanvas() {return (CGlobeCanvas*)m_canvas; }

		void OnDynamicLogScaleCheck( wxCommandEvent& event );
		void OnDynamicSelect(wxListEvent &event);
		void OnDynamicSpecialSelect(wxCommandEvent &event);

		void RefleshPanel();
		void CreateDataForNewFilter();

	private:
		wxListBox	*m_DynamicSpecialListBox;
		wxListCtrl	*m_DynamicListBox;
		wxCheckBox	*m_ScaleCheckBox;

		DECLARE_EVENT_TABLE()
	};

	class CGlobeCanvas: public CCanvas
	{
		friend class CGlobeFrame;

	public:
		CGlobeCanvas(wxWindow *parent, wxWindowID id = wxID_ANY,
			const wxPoint& pos = wxDefaultPosition,
			const wxSize& size = wxDefaultSize,
			long style = 0, const wxString& name = _T("CGlobeCanvas"));
		~CGlobeCanvas(){ delete m_virtualGlobe;};
		void SetLogScale ( bool _value );

		void OnSize(wxSizeEvent& event);
		void OnPaint(wxPaintEvent& event);
		void OnIdle( wxIdleEvent& event );
		void OnMouse( wxMouseEvent& event );

		void Render();


	private:
		void InitOrtho()
		{
			m_Ortho[0] = -0.1f;
			m_Ortho[1] = 1.06f;
			m_Ortho[2] = -0.1f;
			m_Ortho[3] = 1.06f;
			m_Ortho[4] = -1.0f;
			m_Ortho[5] = 1.0f;
		}
		void DrawAxis();
		void DrawCanvas();
		void SelectData();
		void InitGL();

		void RenderVBO();
		void DrawIndication();

		void SetShader();

		void virtualGlobe();
		bool m_if_loadGlobe;
		void loadGlobe();

		CVirtualGlobe* m_virtualGlobe;

		int m_mouseX, m_mouseY;
		int m_mouseXRef, m_mouseYRef;
		int m_width,  m_height;

		DECLARE_EVENT_TABLE()
	};


}
